<%@ page language="java"  pageEncoding="utf-8"%>
<%@taglib uri="/WEB-INF/struts-tags.tld" prefix="s"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>权限管理</title>
<%@include file="../common/jscss.jsp" %>
</head>

<body>
	<!-- head -->
	<%@include file="../common/header.jsp" %>
    <!-- head--end -->
    <div class="content">
    	<div class="p_pd_s1">
            <div class="box_s4">
                <div class="title"><img src="images/other/icon_16.jpg" /><div class="manage_sorts"><a href="member!editRole.do">权限管理</a>&nbsp;&nbsp;&nbsp;<a href="member!userList.do" style="color: gray;">通讯录管理</a></div></div>
                <div class="p_content clearfix">
                	<div class="tree_box pl30">
                    	<h3>选择组</h3>
                    	<ul class="tree_menu" id="contact_tree">
                    	<s:iterator value="roleTree" id="roleTree">
                    		<li class="t_s1 spread pl10" roleId="<s:property value="id"/>">
                            	<i><s:property value="name"/></i>
                            	<s:if test="#roleTree.roleList != null && #roleTree.roleList.size() > 0">
                            		<ul style="display:none;">
                            			<s:iterator value="#roleTree.roleList" id="roleTree2">
                            				<li class="t_s2 spread pl10 " roleId="<s:property value="id"/>">
		                                    	<i><s:property value="name"/></i>
		                                    	<s:if test="#roleTree2.roleList != null && #roleTree2.roleList.size() > 0">
		                                        <ul class="tree_child" style="display:none;">
		                                        	<s:iterator value="#roleTree2.roleList" id="roleTree3">
		                                        	<li roleId="<s:property value="id"/>"><i><s:property value="name"/></i></li>
		                                            </s:iterator>
		                                        </ul>
		                                        </s:if>
		                                    </li>
                            			</s:iterator>
	                                	
	                                </ul>
                            	</s:if>
                                
                             </li>
                    	</s:iterator>
                        </ul>
                        	
                        
                   </div>
                    
                    <!-- purview_detail -->
                    <div class="purview_detail_box" id="edit_role_right">
                    	<div class="p_d_head"></div>
                        <div class="p_d_content">
                        	<form>
                        	<div class="com_purview">
                            	<h3>信息管理</h3>
                                <table class="p_table" cellpadding="0" cellspacing="0" width="165" id="p_message">
                                	<thead>
                                    	<tr>
                                        	<th width="60"><span>发布</span><span>查看</span></th>
                                            <th width="105"></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    	<tr>
						<td width="60" class="tc">
							<input
								<s:if test="role.chargeRes.indexOf('1') != -1">checked="checked" value="1"</s:if>
								type="checkbox" id="gzxx_fb" class="release cb" />
							<input
								<s:if test="role.accessRes.indexOf('1') != -1">checked="checked"</s:if>
								<s:if test="role.chargeRes.indexOf('1') != -1">disabled="disabled"</s:if>
								type="checkbox" id="gzxx_ck" class=" check cb" />
						</td>
						<td width="105">
							<span class=" p_info">高招信息</span>
						</td>
					</tr>
					<tr>
						<td width="60" class="tc">
							<input
								<s:if test="role.chargeRes.indexOf('2') != -1">checked="checked" value="1"</s:if>
								type="checkbox" id="zzxx_fb" class="release cb" />
							<input
								<s:if test="role.accessRes.indexOf('2') != -1">checked="checked"</s:if>
								<s:if test="role.chargeRes.indexOf('2') != -1">disabled="disabled"</s:if>
								type="checkbox" id="zzxx_ck" class=" check cb" />
						</td>
						<td width="105">
							<span class=" p_info">中招信息</span>
						</td>
					</tr>
					<tr>
						<td width="60" class="tc">
							<input
								<s:if test="role.chargeRes.indexOf('3') != -1">checked="checked" value="1"</s:if>
								type="checkbox" id="czzs_fb" class="release cb" />
							<input
								<s:if test="role.accessRes.indexOf('3') != -1">checked="checked"</s:if>
								<s:if test="role.chargeRes.indexOf('3') != -1">disabled="disabled"</s:if>
								type="checkbox" id="czzs_ck" class=" check cb" />
						</td>
						<td width="105">
							<span class=" p_info">初中招生</span>
						</td>
					</tr>
					<tr>
						<td width="60" class="tc">
							<input
								<s:if test="role.chargeRes.indexOf('6') != -1">checked="checked" value="1"</s:if>
								type="checkbox" id="xyks_fb" class="release cb" />
							<input
								<s:if test="role.accessRes.indexOf('6') != -1">checked="checked"</s:if>
								<s:if test="role.chargeRes.indexOf('6') != -1">disabled="disabled"</s:if>
								type="checkbox" id="xyks_ck" class=" check cb" />
						</td>
						<td width="105">
							<span class=" p_info">学业考试</span>
						</td>
					</tr>
					<tr>
						<td width="60" class="tc">
							<input
								<s:if test="role.chargeRes.indexOf('7') != -1">checked="checked" value="1"</s:if>
								type="checkbox" id="zxxj_fb" class="release cb" />
							<input
								<s:if test="role.accessRes.indexOf('7') != -1">checked="checked"</s:if>
								<s:if test="role.chargeRes.indexOf('7') != -1">disabled="disabled"</s:if>
								type="checkbox" id="zxxj_ck" class=" check cb" />
						</td>
						<td width="105">
							<span class=" p_info">中学学籍</span>
						</td>
					</tr>
					<tr>
						<td width="60" class="tc">
							<input
								<s:if test="role.chargeRes.indexOf('8') != -1">checked="checked" value="1"</s:if>
								type="checkbox" id="xxxj_fb" class="release cb" />
							<input
								<s:if test="role.accessRes.indexOf('8') != -1">checked="checked"</s:if>
								<s:if test="role.chargeRes.indexOf('8') != -1">disabled="disabled"</s:if>
								type="checkbox" id="xxxj_ck" class=" check cb" />
						</td>
						<td width="105">
							<span class=" p_info">小学学籍</span>
						</td>
					</tr>
					<tr>
						<td width="60" class="tc">
							<input
								<s:if test="role.chargeRes.indexOf('9') != -1">checked="checked" value="1"</s:if>
								type="checkbox" id="jxxx_fb" class="release cb" />
							<input
								<s:if test="role.accessRes.indexOf('9') != -1">checked="checked"</s:if>
								<s:if test="role.chargeRes.indexOf('9') != -1">disabled="disabled"</s:if>
								type="checkbox" id="jxxx_ck" class=" check cb" />
						</td>
						<td width="105">
							<span class=" p_info">教学信息</span>
						</td>
					</tr>
					<!--
                    <tr>
                    	<td width="60" class="tc"><input type="checkbox" id="rcgl_fb" class="release cb" /><input type="checkbox" id="rcgl_ck" class=" check cb" /></td>
                        <td width="105"><span class=" p_info">日程管理</span></td>
                    </tr>
                    -->
					<tr>
						<td width="60" class="tc">
							<input type="checkbox" class="cb" id="release_all" />
							<input type="checkbox" class="cb" id="check_all" />
						</td>
						<td width="105">
							<span class=" p_info">全部</span>
						</td>
					</tr>
                                    </tbody>
                                </table>
                            </div>
                            
                            <div class="com_purview">
                            	<h3>功能管理</h3>
                                <table class="p_table" cellpadding="0" cellspacing="0" width="165" id="p_message">
                                    <tr>
                                    
                                        <td width="15" class="tc"><input id="mang_user" type="checkbox" <s:if test="role.userMang">checked="checked"</s:if>/></td>
                                        <td width="150"><span class=" p_info">管理通讯录</span></td>
                                    </tr>
                                    <tr>
                                    
                                        <td width="15" class="tc"><input id="schedule_mang" type="checkbox" <s:if test="role.scheduleMang">checked="checked"</s:if>/></td>
                                        <td width="150"><span class=" p_info">日程管理</span></td>
                                    </tr>
                                    <tr>
                                        <td width="15" class="tc"><input id="can_login" type="checkbox" <s:if test="role.login">checked="checked"</s:if>/></td>
                                        <td width="150"><span class=" p_info">登录网站</span></td>
                                    </tr>
                                    <tr>
                                        <td width="15" class="tc"><input id="send_msg" type="checkbox" <s:if test="role.msgsend">checked="checked"</s:if>/></td>
                                        <td width="150"><span class=" p_info">发送短信</span></td>
                                    </tr>
                                </table>
                            </div>
                            
                            <div class="com_purview">
                            	<h3>访问通讯录</h3>
                                <table class="p_table" cellpadding="0" cellspacing="0" width="165" id="p_message">
                                    <tr>
                                        <td width="15" class="tc"><input <s:if test="role.visituser==1">checked="checked"</s:if> type="radio" value="1" class="sort1"  name="c_group"/></td>
                                        <td width="150"><span class=" p_info">所有通讯录</span></td>
                                    </tr>
                                    <tr>
                                        <td width="15" class="tc"><input <s:if test="role.visituser==2 || role.visituser==3">checked="checked"</s:if> type="radio" class="sort2" value="2" name="c_group"/></td>
                                        <td width="150"><span class=" p_info">招办通讯录</span></td>
                                    </tr><!--
                                    <tr>
                                        <td colspan="2" >
											<table cellpadding="0" cellspacing="0" class="ml20">
                                            	<tr>
                                                	<td><input type="radio" class="sort2 group_sort" <s:if test="role.visituser==2">checked="checked"</s:if> name="c_group" value="2"/></td><td><span class=" p_info">所有组</span></td>
                                                </tr>
                                                <tr>
                                                	<td><input type="radio" class="sort2 group_sort" <s:if test="role.visituser==3">checked="checked"</s:if>  name="c_group" value="3"/></td><td><span class=" p_info">相同组</span></td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                --></table>
                            </div>
                            <div class="clear"></div>
                            <input type="button" value="保存" class="def_btn_s1 ml20 mt40" onclick="saveRole();"/>
                            </form>
                        </div>
                        <div class="p_d_foot"></div>
                    </div>
                    <!-- purview_detail--end -->
                    
                </div>
            </div>
        </div>
    </div>
    <div style="clear: both;"></div>
    <%@include file="../common/footer.jsp" %>
    
    <script type="text/javascript">
    	var editRoleId = "";
		$(function(){
			$.defUnit.treeMenu({
				callback:function(obj){
				//	alert($(obj).attr("roleId"));
					var roleId = $(obj).attr("roleId");
					editRoleId = roleId;
					$("#edit_role_right").load("member!editRoleRight.do?id="+editRoleId);
				}
			});
			$.defUnit.purviewFunc();
		});
		
		function saveRole(){
			var gzxx_fb = $("#gzxx_fb").attr("checked")?true:false;
			var gzxx_ck = $("#gzxx_ck").attr("checked")?true:false;
			
			var zzxx_fb = $("#zzxx_fb").attr("checked")?true:false;
			var zzxx_ck = $("#zzxx_ck").attr("checked")?true:false;
			
			var czzs_fb = $("#czzs_fb").attr("checked")?true:false;
			var czzs_ck = $("#czzs_ck").attr("checked")?true:false;
			
			var xyks_fb = $("#xyks_fb").attr("checked")?true:false;
			var xyks_ck = $("#xyks_ck").attr("checked")?true:false;
			
			var zxxj_fb = $("#zxxj_fb").attr("checked")?true:false;
			var zxxj_ck = $("#zxxj_ck").attr("checked")?true:false;
			
			var xxxj_fb = $("#xxxj_fb").attr("checked")?true:false;
			var xxxj_ck = $("#xxxj_ck").attr("checked")?true:false;
			
			var jxxx_fb = $("#jxxx_fb").attr("checked")?true:false;
			var jxxx_ck = $("#jxxx_ck").attr("checked")?true:false;
			
			
			
			
			var chargeRes = "";
			var i = 0;
			if(gzxx_fb){
				if(i!=0){
					chargeRes+=",";
				}
				chargeRes+="1";
				i++;
			}
			if(zzxx_fb){
				if(i!=0){
					chargeRes+=",";
				}
				chargeRes+="2";
				i++;
			}
			if(czzs_fb){
				if(i!=0){
					chargeRes+=",";
				}
				chargeRes+="3";
				i++;
			}
			if(xyks_fb){
				if(i!=0){
					chargeRes+=",";
				}
				chargeRes+="6";
				i++;
			}
			if(zxxj_fb){
				if(i!=0){
					chargeRes+=",";
				}
				chargeRes+="7";
				i++;
			}
			if(xxxj_fb){
				if(i!=0){
					chargeRes+=",";
				}
				chargeRes+="8";
				i++;
			}
			if(jxxx_fb){
				if(i!=0){
					chargeRes+=",";
				}
				chargeRes+="9";
				i++;
			}
			
			
			var accessRes = "";
			var i = 0;
			if(gzxx_ck){
				if(i!=0){
					accessRes+=",";
				}
				accessRes+="1";
				i++;
			}
			if(zzxx_ck){
				if(i!=0){
					accessRes+=",";
				}
				accessRes+="2";
				i++;
			}
			if(czzs_ck){
				if(i!=0){
					accessRes+=",";
				}
				accessRes+="3";
				i++;
			}
			if(xyks_ck){
				if(i!=0){
					accessRes+=",";
				}
				accessRes+="6";
				i++;
			}
			if(zxxj_ck){
				if(i!=0){
					accessRes+=",";
				}
				accessRes+="7";
				i++;
			}
			if(xxxj_ck){
				if(i!=0){
					accessRes+=",";
				}
				accessRes+="8";
				i++;
			}
			if(jxxx_ck){
				if(i!=0){
					accessRes+=",";
				}
				accessRes+="9";
				i++;
			}
			var mang_user = $("#mang_user").attr("checked")?true:false;
			var schedule_mang = $("#schedule_mang").attr("checked")?true:false;
			var can_login = $("#can_login").attr("checked")?true:false;
			var send_msg = $("#send_msg").attr("checked")?true:false;
			var visituser = $('input[name="c_group"]:checked').val();
			if(editRoleId==""){
				alert("请选择授权分组");
				return ;
			}
			$.post("member!saveRole.do",{
				'role.id':editRoleId,
				'role.chargeRes':chargeRes,
				'role.accessRes':accessRes,
				'role.userMang':mang_user,
				'role.scheduleMang':schedule_mang,
				'role.login':can_login,
				'role.msgsend':send_msg,
				'role.visituser':visituser,
				'role.authed':true
			},function(data){
				var ret = $.parseJSON(data);
				alert(ret.msg);
			});
		}
	</script>
</body>
</html>
